package com.sun;



import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class CreateFile {
    public static void main(String[] args) {

    }

    @Test
    public void test1(){
        File file = new File("D:\\中科软信息\\自学\\io\\new1.txt");
        try {
            file.createNewFile();
            System.out.println("创建成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    //方式2  new File(File parent,String child)  根据父目录文件+子路径构建
    @Test
    public void test2(){
        File parentPath = new File("D:\\中科软信息\\自学\\io\\");
        String fileName = "new2.txt";
        File file = new File(parentPath, fileName);
        try {
            file.createNewFile();
            System.out.println("new2创建成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

